#!/bin/sh
# set -euxo pipefail
cd tests

rm -rf tests.log

# known good tests
TESTS="\
credentials_create_destroy_test \
anonymous_credentials_create_destroy_test \
static_credentials_provider_basic_test \
anonymous_credentials_provider_basic_test \
environment_credentials_provider_basic_test \
environment_credentials_provider_negative_test \
cached_credentials_provider_elapsed_test \
cached_credentials_provider_expired_test \
cached_credentials_provider_queued_async_test \
profile_credentials_provider_new_destroy_defaults_test \
profile_credentials_provider_default_test \
profile_credentials_provider_nondefault_test \
profile_credentials_provider_environment_test \
credentials_provider_first_in_chain_test \
credentials_provider_second_in_chain_test \
credentials_provider_null_chain_test \
credentials_provider_default_basic_test \
credentials_provider_default_manual_tls_test \
credentials_provider_imds_new_destroy \
credentials_provider_imds_connect_failure \
credentials_provider_imds_token_request_failure \
credentials_provider_imds_role_name_request_failure \
credentials_provider_imds_role_request_failure \
credentials_provider_imds_bad_document_failure \
credentials_provider_imds_secure_success \
credentials_provider_imds_connection_closed_success \
credentials_provider_imds_insecure_success \
credentials_provider_imds_insecure_then_secure_success \
credentials_provider_imds_success_multi_part_role_name \
credentials_provider_imds_success_multi_part_doc \
credentials_provider_imds_real_new_destroy \
credentials_provider_ecs_new_destroy \
credentials_provider_ecs_connect_failure \
credentials_provider_ecs_request_failure \
credentials_provider_ecs_bad_document_failure \
credentials_provider_ecs_basic_success \
credentials_provider_ecs_no_auth_token_success \
credentials_provider_ecs_success_multi_part_doc \
credentials_provider_ecs_real_new_destroy \
credentials_provider_x509_new_destroy \
credentials_provider_x509_connect_failure \
credentials_provider_x509_request_failure \
credentials_provider_x509_bad_document_failure \
credentials_provider_x509_basic_success \
credentials_provider_x509_success_multi_part_doc \
credentials_provider_x509_real_new_destroy \
credentials_provider_sts_web_identity_new_destroy_from_env \
credentials_provider_sts_web_identity_new_destroy_from_config \
credentials_provider_sts_web_identity_new_failed_without_env_and_config \
credentials_provider_sts_web_identity_connect_failure \
credentials_provider_sts_web_identity_request_failure \
credentials_provider_sts_web_identity_bad_document_failure \
credentials_provider_sts_web_identity_test_retry_error1 \
credentials_provider_sts_web_identity_test_retry_error2 \
credentials_provider_sts_web_identity_basic_success_env \
credentials_provider_sts_web_identity_basic_success_config \
credentials_provider_sts_web_identity_success_multi_part_doc \
credentials_provider_sts_web_identity_real_new_destroy \
credentials_provider_sts_direct_config_succeeds \
credentials_provider_sts_direct_config_succeeds_after_retry \
credentials_provider_sts_direct_config_invalid_doc \
credentials_provider_sts_direct_config_connection_failed \
credentials_provider_sts_direct_config_service_fails \
credentials_provider_sts_from_profile_config_succeeds \
credentials_provider_sts_from_profile_config_manual_tls_succeeds \
credentials_provider_sts_from_profile_config_environment_succeeds \
credentials_provider_sts_cache_expiration_conflict \
credentials_provider_process_new_destroy_from_config \
credentials_provider_process_new_destroy_from_config_without_token \
credentials_provider_process_new_failed \
credentials_provider_process_bad_command \
credentials_provider_process_incorrect_command_output \
credentials_provider_process_basic_success \
credentials_provider_cognito_new_destroy \
credentials_provider_cognito_failure_connect \
credentials_provider_cognito_failure_request \
credentials_provider_cognito_failure_bad_document \
credentials_provider_cognito_success \
credentials_provider_cognito_success_after_retry \
imds_client_new_release \
imds_client_connect_failure \
imds_client_token_request_failure \
imds_client_resource_request_failure \
imds_client_resource_request_success \
imds_client_insecure_resource_request_success \
imds_client_insecure_then_secure_resource_request_success \
imds_client_multiple_resource_requests_random_responses_finally_all_success \
imds_client_get_ami_id_success \
imds_client_get_ancestor_ami_ids_success \
imds_client_get_iam_profile_success \
imds_client_get_instance_info_success \
imds_client_get_credentials_success \
config_file_path_override_test \
config_file_path_environment_test \
credentials_file_path_override_test \
credentials_file_path_environment_test \
profile_override_test \
profile_environment_test \
sigv4_skip_xray_header_test \
sigv4_skip_user_agent_header_test \
sigv4_skip_custom_header_test \
sigv4_fail_date_header_test \
sigv4_fail_content_header_test \
sigv4_fail_authorization_header_test \
sigv4_fail_signature_param_test \
sigv4_fail_date_param_test \
sigv4_fail_credential_param_test \
sigv4_fail_algorithm_param_test \
sigv4_fail_signed_headers_param_test \
signer_null_credentials_test \
signer_anonymous_credentials_test \
signer_anonymous_credentials_provider_test \
sigv4_chunked_signing_test \
sigv4a_chunked_signing_test \
sigv4_trailing_headers_signing_test \
sigv4a_trailing_headers_signing_test \
credentials_derive_ecc_key_fixed \
credentials_new_ecc_fixed \
credentials_derive_ecc_key_long_access_key \
be_sequence_add_one \
be_sequence_compare \
sigv4a_get_header_key_duplicate_test \
sigv4a_get_header_value_multiline_test \
sigv4a_get_header_value_order_test \
sigv4a_get_header_value_trim_test \
sigv4a_get_unreserved_test \
sigv4a_get_utf8_test \
sigv4a_get_vanilla_test \
sigv4a_get_vanilla_with_session_token_test \
sigv4a_get_vanilla_empty_query_key_test \
sigv4a_get_vanilla_query_test \
sigv4a_get_vanilla_query_order_key_case_test \
sigv4a_get_vanilla_query_order_encoded_test \
sigv4a_get_vanilla_unreserved_test \
sigv4a_get_vanilla_utf8_query_test \
sigv4a_post_header_key_case_test \
sigv4a_post_header_key_sort_test \
sigv4a_post_header_value_case_test \
sigv4a_post_vanilla_test \
sigv4a_post_vanilla_empty_query_value_test \
sigv4a_post_vanilla_query_test \
sigv4a_post_x_www_form_urlencoded_test \
sigv4a_post_x_www_form_urlencoded_parameters_test \
sigv4a_post_sts_header_after_test \
sigv4a_post_sts_header_before_test \
sigv4a_get_relative_normalized_test \
sigv4a_get_relative_unnormalized_test \
sigv4a_get_relative_relative_normalized_test \
sigv4a_get_relative_relative_unnormalized_test \
sigv4a_get_slash_normalized_test \
sigv4a_get_slash_unnormalized_test \
sigv4a_get_slash_dot_slash_normalized_test \
sigv4a_get_slash_dot_slash_unnormalized_test \
sigv4a_get_slash_pointless_dot_normalized_test \
sigv4a_get_slash_pointless_dot_unnormalized_test \
sigv4a_get_slashes_normalized_test \
sigv4a_get_slashes_unnormalized_test \
sigv4a_get_space_normalized_test \
sigv4a_get_space_unnormalized_test \
sigv4_get_header_key_duplicate_test \
sigv4_get_header_value_multiline_test \
sigv4_get_header_value_order_test \
sigv4_get_header_value_trim_test \
sigv4_get_unreserved_test \
sigv4_get_utf8_test \
sigv4_get_vanilla_test \
sigv4_get_vanilla_with_session_token_test \
sigv4_get_vanilla_empty_query_key_test \
sigv4_get_vanilla_query_test \
sigv4_get_vanilla_query_order_key_case_test \
sigv4_get_vanilla_query_order_encoded_test \
sigv4_get_vanilla_unreserved_test \
sigv4_get_vanilla_utf8_query_test \
sigv4_post_header_key_case_test \
sigv4_post_header_key_sort_test \
sigv4_post_header_value_case_test \
sigv4_post_vanilla_test \
sigv4_post_vanilla_empty_query_value_test \
sigv4_post_vanilla_query_test \
sigv4_post_x_www_form_urlencoded_test \
sigv4_post_x_www_form_urlencoded_parameters_test \
sigv4_post_sts_header_after_test \
sigv4_post_sts_header_before_test \
sigv4_get_relative_normalized_test \
sigv4_get_relative_unnormalized_test \
sigv4_get_relative_relative_normalized_test \
sigv4_get_relative_relative_unnormalized_test \
sigv4_get_slash_normalized_test \
sigv4_get_slash_unnormalized_test \
sigv4_get_slash_dot_slash_normalized_test \
sigv4_get_slash_dot_slash_unnormalized_test \
sigv4_get_slash_pointless_dot_normalized_test \
sigv4_get_slash_pointless_dot_unnormalized_test \
sigv4_get_slashes_normalized_test \
sigv4_get_slashes_unnormalized_test \
sigv4_get_space_normalized_test \
sigv4_get_space_unnormalized_test \
"

for TEST in $TESTS
do
./aws-c-auth-tests $TEST >> tests.log
done

sed  -e '/OK/ s/^/PASS: / ; /FAILED/ s/^/FAIL: / ; /ERROR/ s/^/FAIL: /' tests.log
